home *** CD-ROM | disk | FTP | other *** search
- Path: xanth!nic.MR.NET!hal!ncoast!allbery
- From: hjt%UUCP.warwick@CUNYVM.CUNY.EDU (Harv (Max) Thompson)
- Newsgroups: comp.sources.misc
- Subject: v05i079: Iconise -- convert SunView icons to text
- Keywords: icons, SunView, Suntools, garfield
- Message-ID: <869@ubu.warwick.UUCP>
- Date: 10 Dec 88 02:18:48 GMT
- Sender: allbery@ncoast.UUCP
- Reply-To: hjt%UUCP.warwick@CUNYVM.CUNY.EDU (Harv (Max) Thompson)
- Organization: Computer Science, Warwick University, UK
- Lines: 345
- Approved: allbery@ncoast.UUCP
-
- Posting-number: Volume 5, Issue 79
- Submitted-by: "Harv (Max" <hjt%UUCP.warwick@CUNYVM.CUNY.EDU>
- Archive-name: iconise
-
- [That From: line looks a bit weird: beware when replying! ++bsa]
-
- For all those lucky enough to have access to SunView / Suntools on
- any type of Sun graphical workstation here is a shar containing a neat
- program to build a text version of all your favourite icons...
-
- In fact this program should work on any machine - all you need is at least
- 64 * 18 character display, a standard C compiler, and access
- (downloads) of the afore mentioned icon files.
-
- Im not to sure if any other icon formats exist - mail me if you have any
- fixes / bugs or ideas.
-
- Have fun
- Harv J "Max" Thompson
-
- #! /bin/sh
- # This is a shell archive, meaning:
- # 1. Remove everything above the #! /bin/sh line.
- # 2. Save the resulting text in a file.
- # 3. Execute the file with /bin/sh (not csh) to create the files:
- # README.iconise
- # garfield.icon2
- # iconise.1
- # iconise.c
- # This archive created: Fri Dec 9 13:01:43 1988
- # By: Harvey J Thompson ()
- export PATH; PATH=/bin:$PATH
- if test -f 'README.iconise'
- then
- echo shar: will not over-write existing file "'README.iconise'"
- else
- cat << \SHAR_EOF > 'README.iconise'
- SHIPPING: Contents
- README.iconise This file
- iconise.c Source file
- garfield.icon2 Test icon
- iconise.1 Nroff source for man entry
-
- See iconise.c and iconise.1 (nroff type manual entry) for description
- of the program. To compile it use:
-
- cc -O -o iconise iconise.c
-
- as a test try:
-
- iconise -w 2 -h 1 garfield.icon2 | (some printer with 132 * 66 page)
-
- or on any 64*18 or larger screen...
-
- iconise garfield.icon2
-
- It is a very simple program I wrote since we at Warwick University
- have periodic access to Sun Graphics workstations and miss our LOVELY icons...
-
- The garfield icon was by me also - just shows that at least a few computer
- nerds actually can do other things than write silly programs.
-
- ______________________________________________________________________________
-
- Snail Mail: ________________ Aliases:
- Harv J Thompson \ \__________ / Well they call me "Max"
- Dept. Of Computer Science \ \______ / /
- University Of Warwick \ __ / / / Quote:
- Coventry CV4 7AL \ \ \/ / / "I smell like a good cup of coffee"
- ENGLAND \ \ / / - said by me at around 5am after
- \ \/ / a particularly long nights hacking
- E-mail: \/ / session!
- hjt@opal.warwick.ac.uk (1988-) \/
- ______________________________________________________________________________
- SHAR_EOF
- fi # end of overwriting check
- if test -f 'garfield.icon2'
- then
- echo shar: will not over-write existing file "'garfield.icon2'"
- else
- cat << \SHAR_EOF > 'garfield.icon2'
- /* Format_version=1, Width=64, Height=64, Depth=1, Valid_bits_per_item=16
- */
- 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0x8000,0x0000,0x0000,0x0003,
- 0x8000,0x0000,0x0000,0x0003,0x8000,0x0F80,0x3E00,0x0003,
- 0x8000,0x1FE0,0xFF00,0x0003,0x8000,0x1FD1,0x3F00,0x0003,
- 0x8000,0x1FCE,0x7F00,0x0003,0x8000,0x2AA0,0xAA80,0x0003,
- 0x8000,0x2AA0,0xAA80,0x0003,0x80F8,0x3551,0x5480,0x0003,
- 0x8006,0x2491,0x2283,0x8003,0x8002,0x6A4A,0x94DC,0x6003,
- 0x8071,0x4004,0x0060,0x0003,0x818D,0x8004,0x007E,0x0003,
- 0x8007,0x0000,0x0033,0x0003,0x800E,0x0000,0x003C,0x8003,
- 0x801E,0x00F1,0xE03E,0x0003,0x803C,0x030A,0x183F,0x0003,
- 0x807C,0x0404,0x043F,0x0003,0x807C,0x0804,0x023C,0x8003,
- 0x80FE,0x0804,0x0230,0x8003,0x80FE,0x0804,0x0200,0x4003,
- 0x809F,0x0804,0x0200,0x6003,0x8100,0x0804,0x0200,0xE003,
- 0x8100,0x0804,0x0200,0xF003,0x8380,0x0804,0x0200,0xF803,
- 0x8380,0x0835,0x8201,0xF803,0x83C0,0xF835,0x83E1,0xC403,
- 0x83E1,0x0835,0x8210,0x0403,0x83F2,0x0804,0x0208,0x0403,
- 0x83E2,0x2404,0x0488,0x0403,0x8380,0x420E,0x0848,0x0C03,
- 0x8300,0xF1FF,0xF1E0,0x3C03,0x8300,0x480E,0x0240,0x7C03,
- 0x8200,0x4C35,0x8640,0xFC03,0x8200,0x4BE4,0xFA40,0x7803,
- 0x8200,0x3924,0x9380,0x3803,0x8200,0x2D24,0x9680,0x1003,
- 0x8300,0x2BFF,0xFA80,0x1003,0x81C0,0x2924,0x9280,0x1003,
- 0x81F0,0x2924,0x9280,0x3003,0x81F0,0x1924,0x9308,0x6003,
- 0x81F0,0x0924,0x920F,0xC003,0x80E0,0x07FF,0xFC0F,0xC003,
- 0x80C0,0x0000,0x000F,0x8003,0x80C0,0x6000,0x030F,0x0003,
- 0x8021,0xE000,0x070E,0x0003,0x803F,0xE000,0x07CC,0x0003,
- 0x8007,0xE000,0x07F0,0x0003,0x8000,0xF0C0,0xCF00,0x0183,
- 0x8000,0x1F00,0x3C00,0x0183,0x8000,0x0000,0x0000,0x0383,
- 0x8000,0x0000,0x0000,0x0303,0x83C2,0x1E7B,0xBD07,0x8303,
- 0x8405,0x1141,0x2104,0x4703,0x8805,0x1141,0x2104,0x4603,
- 0x89C8,0x9E71,0x3904,0x4003,0x884F,0x9141,0x2104,0x4003,
- 0x8850,0x5141,0x2104,0x4C03,0x8790,0x5143,0xBDF7,0x8C03,
- 0x8000,0x0000,0x0000,0x0003,0x8000,0x0000,0x0000,0x0003,
- 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF
- SHAR_EOF
- chmod +x 'garfield.icon2'
- fi # end of overwriting check
- if test -f 'iconise.1'
- then
- echo shar: will not over-write existing file "'iconise.1'"
- else
- cat << \SHAR_EOF > 'iconise.1'
- .TH ICONISE 1 "23rd November 1988"
- .\"@(#)iconise.1 1.1 87/04/29 SMI;
- .SH NAME
- iconise \- produces ASCII image of an icon produced on SunView
- .SH SYNOPSIS
- iconise [-h ratio] [-w ratio] file
- .SH DESCRIPTION
- .LP
- This program takes a standard icon image file produced under SunView, or
- Suntools on standard Sun workstations. The result is printed on
- standard-out, and so the program maybe used as a pipe. The options
- have the following effect;
- .RS
- .nf
- .TP 20
- -h ratio
- Allows height compression of either 1, 2 or 4
- pixels. The default is 4 pixels. (NB. Density
- mapping is performed.)
- .TP
- -w ratio
- Allows width expansion of either 1, 2 or 4 pixels.
- The default is 1 pixel.
- .fi
- .RE
- .LP
- The best result for printouts would be obtained by;
- .IP
- iconise -h 1 -w 2 <icon-file> | lpr
- .SH BUGS
- .LP
- None found as yet
- .SH AUTHOR
- .LP
- Harvey J "Max" Thompson (hjt@cs.warwick.ac.uk)
- .LP
- (C) 1988 Helios Software Ltd. All rights reserved.
- SHAR_EOF
- chmod +x 'iconise.1'
- fi # end of overwriting check
- if test -f 'iconise.c'
- then
- echo shar: will not over-write existing file "'iconise.c'"
- else
- cat << \SHAR_EOF > 'iconise.c'
- /****************************************************************************\
- * iconise - program to display SunView icon images on terminals
- * (C) 1988 Helios Software Ltd. All rights reserved. Harvey J "Max" Thompson
- * #include <public.domain.h>....
- * This software and its associated source files are now in the PUBLIC DOMAIN
- * - no inclusion in any packages whatsoever for monetry gain is
- * allowed without the written consent of the author. The source files
- * must ( 8- ) be freely distrubited, and any changes must be made in the
- * spirit of PD software - Ie. Dont change any copyrights and authuorships.
- * BUGS+IDEAS+CHANGES: mail me direct at:-
- * JANET: hjt@cs.warwick.ac.uk
- * UUCP: hjt@warwick.UUCP
- * ARPA: hjt%warwick@cs.ucl.ac.uk
- * You should be able to work it out from there.....
- \****************************************************************************/
-
- #include <sys/types.h>
- #include <stdio.h>
- #define MAX_X 64
- #define MAX_Y 64
- #define res_string(xxx,lll) if ((xxx = (char *) malloc (lll)) == NULL)\
- $fprintf(stderr,"%s: Ran out of memory\n",argv[0]);exit(1);
- #define help (void) fprintf(stderr, "Usage: iconise [-h ratio] [-w ratio]
- file\n")
-
- main(argc, argv)
- char **argv;
- int argc;
- $
- FILE *icon;
- char *density = " `\'\"-^=o.:|!;O@#", *file = NULL;
-
- /* you could change density to a better gradient - but this does the */
- /* trick okish */
-
- int fv = 0, wd = 0, ht = 0, dp = 0, vbpi = 0;
- int hratio = 4;
- int wratio = 1;
- int image[MAX_Y][MAX_X], x, y, line, i, j, k;
-
- switch (argc) $
- case 2:
- file = argv[1];
- break;
- case 6:
- file = argv[5];
- if (strcmp (argv[3], "-h") == 0) $
- hratio = atoi(argv[4]);
- if ((hratio != 1) && (hratio != 2) && (hratio != 4)) $
- help;
- exit(1);
-
-
- if (strcmp (argv[3], "-w") == 0) $
- wratio = atoi (argv[4]);
- if ((wratio != 1) && (wratio !=2) && (hratio != 4)) $
- help;
- exit(1);
-
-
- case 4:
- if (file == NULL)
- file = argv[3];
- if (strcmp (argv[1], "-h") == 0) $
- hratio = atoi(argv[2]);
- if ((hratio != 1) && (hratio != 2) && (hratio != 4)) $
- help;
- exit(1);
-
-
- if (strcmp (argv[1], "-w") == 0) $
- wratio = atoi (argv[2]);
- if ((wratio != 1) && (wratio !=2) && (hratio != 4)) $
- help;
- exit(1);
-
-
- break;
- default:
- help;
- exit(1);
-
-
- if ((icon = (FILE *) fopen (file, "r")) == NULL) $
- (void) fprintf (stderr, "%s: file %s not found\n", argv[0], argv[1]);
- exit(1);
-
- (void) fscanf (icon, "\n");
- (void) fscanf (icon, "/* Format_version=%d", &fv);
- (void) fscanf (icon, ", Width=%d", &wd);
- (void) fscanf (icon, ", Height=%d", &ht);
- (void) fscanf (icon, ", Depth=%d", &dp);
- (void) fscanf (icon, ", Valid_bits_per_item=%d\n */", &vbpi);
-
- if (fv != 1) $
- (void) fprintf (stderr, "%s: Unknown icon format\n", argv[0]);
- exit(1);
-
-
- if (dp != 1) $
- (void) fprintf (stderr, "%s: Cannot iconise depth of %d\n", argv[0], dp);
- exit(1);
-
-
- if (wd > MAX_X) $
- (void) fprintf (stderr, "%s: Icon image to wide\n", argv[0]);
- exit(1);
-
-
- if (ht > MAX_Y) $
- (void) fprintf (stderr, "%s: Icon image to high\n", argv[0]);
- exit(1);
-
-
- /* read in the array from the iconfile */
- /* and convert the hex format into a bit image in the array image */
-
- for (y = 0; y < ht; y += 2) $
- (void) fscanf (icon, "\t");
- for (i = 0; i < 2; i++) $
- for (j = 0; j < 4; j++) $
- (void) fscanf (icon, "%i,", &line);
- for (k = 0; k < 16; k++) $
- image[y+i][j*16+k] = (line & 0x8000) >> 15;
- line = (line << 1);
-
-
-
-
-
- /* hratio j (possible density numbers) Really like j as
- * 1 0 1 0 15
- * 2 0 1 2 3 0 5 10 15
- * 4 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 (as it is)
- */
-
- for (y = 0; y < ht; y+=hratio) $
- for (x = 0; x < wd; x++) $
- /* add up the density for the current output square */
- for (j = 0, i = 0; i < hratio; i++) $
- j += (image[y+i][x] << i);
-
- /* make j the correct range */
- switch (hratio) $
- case 1:
- j = j * 15;
- break;
- case 2:
- j = j * 5;
- break;
- default:
- break;
-
- /* print the density a number of times depending on width ratios */
- for (k = 0; k < wratio; k++)
- (void) printf ("%c",density[j]);
-
- (void) printf ("\n");
-
-
- SHAR_EOF
- fi # end of overwriting check
- # End of shell archive
- exit 0
-
- ______________________________________________________________________________
-
- Snail Mail: ________________ Aliases:
- Harv J Thompson \ \__________ / Max
- Dept. Of Computer Science \ \______ / /
- University Of Warwick \ __ / / / Quote:
- Coventry CV4 7AL \ \ \/ / / Dreamers dream of dreams becoming
- \ \ / / reality. Realists realise that
- EMail: \ \/ / realism is a dream. But only I
- \/ / realise that dreams may become
- hjt@opal.warwick.ac.uk (1988-) \/ reality if reality were a dream.
- ______________________________________________________________________________
-